
#include "BulletController.h"

BulletController::BulletController(void)
{
	for(int i = 0; i < 50; i++){
		if(bullets[i] != NULL){
			//delete(bullets[i]);
			bullets[i] = NULL;
		}
	}
}

BulletController::~BulletController(void)
{
}

void BulletController::Update(){
	for(int i = 0; i < 50; i++){
		if(bullets[i] != NULL){
			if(bullets[i]->ticks > 600){
				RemoveBullet(i);
			}
			else{
				if(!bullets[i]->Update()){
					RemoveBullet(i);
				}
			}
		}
	}

}
void BulletController::Draw(HDC graphics){
	for(int i = 0; i < 50; i++){
		if(bullets[i] != NULL){
			bullets[i]->Draw(graphics);
		}
	}
}
void BulletController::AddBullet(CBullet* bullet){
		for(int i = 0; i < 50; i++){
		if(bullets[i] == NULL){
			bullets[i] = bullet;
		}
	}
}

void BulletController::RemoveBullet(int id){
		delete(bullets[id]);
		bullets[id] = NULL;
	
}

void BulletController::NewBullet(int x, int y, double xSpeed, double ySpeed, CPlayer* player1, int shots, bool seed){
		for(int i = 0; i < 50; i++){
		if(bullets[i] == NULL){
			bullets[i] = new CBullet(x,y,xSpeed,ySpeed, player1, i, tiles, shots, seed);
			break;
		}
	}	
}

void BulletController::Reset(){
		
		for(int i = 0; i < 50; i++){
			delete(bullets[i]);
		  bullets[i] = NULL;
		}
}